package com.smart.main;

//import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
import java.sql.Connection;

public class Conexion {

    private String driver = "com.mysql.jdbc.Driver";
    private String host = "jdbc:mysql://localhost:3306/smart2";
    private String usuario = "smart";
    private String clave = "123456";
    private Connection cn = null;

    public Conexion() {
    }

    public Connection getConexion() {
        try {
            Class.forName(driver);
            System.out.println("Driver Mysql Cargado");
            cn = DriverManager.getConnection(host, usuario, clave);
            System.out.println("Conexión con la base de datos Ok.");
        } catch (Exception e) {
            cn = null;
            e.toString();
            System.out.println("Error al conectar a la base de datos");
            System.exit(1);
        }
        return cn;
    }
}
